package com.aaa.controller;

import com.aaa.entity.MyReturn;
import com.aaa.entity.PageSort;
import com.aaa.entity.TblTestPlanFpa;
import com.aaa.service.TestPlanFpaService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @Author: whr
 * @Description TestPlanFpaController控制层
 * @Date
 * @Modifiel
 */
@Controller
@RequestMapping("testPlanFpa")
public class TestPlanFpaController extends BaseController{

    @Autowired
    private TestPlanFpaService testPlanFpaService;

    private MyReturn myReturn = new MyReturn();

    @RequestMapping("testPlan.do")
    public String Page(){
        return "showTblTestPlanFpa";
    }
    /**
     * 查询 模糊查询
     * @param pageSort
     * @return MyReturn
     */
    @ResponseBody
    @RequestMapping("select.do")
    public MyReturn selectTestPlanFpa(PageSort pageSort){
        Page page = testPlanFpaService.selectTblTestPlanFpa(pageSort);
        /**
         * 获取总条数
         */
        myReturn.setCount(page.getTotal());
        /**
         * 获取结果
         */
        myReturn.setData(page.getResult());
        return super.getSuccessResult(myReturn);
    }

    /**
     * 添加测试
     * @param tblTestPlanFpa
     * @return MyReturn
     */
    @ResponseBody
    @RequestMapping("insert.do")
    public MyReturn insertTestPlanFpa(TblTestPlanFpa tblTestPlanFpa){
        boolean b = testPlanFpaService.insertTblTestPlanFpa(tblTestPlanFpa);
        if (b){
            return super.getSuccessResult(myReturn);
        }
        return super.getFailResult(myReturn);
    }

    /**
     * 修改测试
     * @param tblTestPlanFpa
     * @return MyReturn
     */
    @ResponseBody
    @RequestMapping("update.do")
    public MyReturn updateTestPlanFpa(TblTestPlanFpa tblTestPlanFpa){
        boolean b = testPlanFpaService.updateTblTestPlanFpa(tblTestPlanFpa);
        if (b){
            return super.getSuccessResult(myReturn);
        }
        return super.getFailResult(myReturn);
    }

    /**
     * 删除测试
     * @param id
     * @return MyReturn
     */
    @ResponseBody
    @RequestMapping("delete.do")
    public MyReturn deleteTestPlanFpa(String id){
        boolean b = testPlanFpaService.deleteTblTestPlanFpa(id);
        if (b){
            return super.getSuccessResult(myReturn);
        }
        return super.getFailResult(myReturn);
    }
}
